#include "share/bitset.h"
#include "share/clock.h"
#include <bitset>
#include <assert.h>

#define BITS 20000
#define TESTS 40000

bool test_bitset() {
    my_bitset_t<BITS> bbits;
    int num = 0;
    for (int i=0; i<BITS; ++i) {
        bool set = rand()%2;
        bbits.set(i, set);
        if (set) {
            ++num;
        }
    }
    assert(num == bbits.get_1num());

    my_bitset_t<BITS> bbits2;

    for (size_t i=0; i<bbits.uint32_num(); ++i) {
        bbits2.set_uint32(i, bbits.get_uint32(i));
    }

    assert(num == bbits2.get_1num());

    my_bitset_t<BITS> sbits;
    my_bitset_t<BITS> bits;

    double start = my_clock_t::get_time();
    for (int k=0; k<TESTS; ++k) {
        for (int i=0; i<BITS; ++i) {
            bool set = rand()%2;
            sbits.set(i, set);
        }
    }
    double end = my_clock_t::get_time();
    printf("sbit %f\n", end-start);

    start = my_clock_t::get_time();
    for (int k=0; k<TESTS; ++k) {
        for (int i=0; i<BITS; ++i) {
            bool set = rand()%2;
            bits.set(i, set);
        }
    }
    end = my_clock_t::get_time();
    printf("bit %f\n", end-start);



    return true;
}
